/**
 *    title:  ftpclient.h
 *    author:  sleeeeeping
 *    created:  2024-08-21 10:08:57
**/
#ifndef _FTPCLIENT_H__
#define _FTPCLIENT_H__

#include "network.h"

#define BUF_LEN 128
#define CMD_LEN 128
#define ARG_LEN 128

typedef struct FTPClient {
    NetWork *cnw;
    NetWork *dnw;
    char sbuf[BUF_LEN];
    char rbuf[BUF_LEN]; 
    int resultCode; 
} FTPClient;

typedef struct Command {
    const char *cmd;
    int (*func)(FTPClient *, const char *);
} Command;

extern Command cmds[];
extern size_t cmdCnt;

FTPClient *createFtpClient(const char *, unsigned short ); // 连接服务器
int userFtpClient(FTPClient *, const char *);
int passFtpClient(FTPClient *, const char *);

// 登录后可执行的相关命令
int lsFtpClient(FTPClient *, const char *);
int pwdFtpClient(FTPClient *, const char *);
int cdFtpClient(FTPClient *, const char *);
int mkdirFtpClient(FTPClient *, const char *);
int rmFtpClient(FTPClient *, const char *);
int putFtpClient(FTPClient *, const char *);
int getFtpClient(FTPClient *, const char *);
int byeFtpClient(FTPClient *, const char *);

// 销毁
int destroyFtpClient(FTPClient *);

#endif // _FTPCLIENT_H__